import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"
from transformers import BertTokenizer
from transformers import BertModel,pipeline
import pandas as pd

tokenizer = BertTokenizer.from_pretrained('bert-base-uncased',cache_dir='i:/models')
model = BertModel.from_pretrained('BERT-base-uncased',cache_dir='i:/models')
text = 'Using Transformer is easy!'
encode_input = tokenizer(text,return_tensors='pt')
decode_txt = model(**encode_input)
# print(decode_txt)
unmasker = pipeline('fill-mask',model='BERT-base-uncased')
print(unmasker('The man worked as a [MASK].'))
df = pd.DataFrame(unmasker('The man worked as a [MASK].'))
print(df)